package com.coursehub.course.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 班级资料关联实体类
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "classes_material")
public class ClassesMaterial {
    
    @EmbeddedId
    private ClassesMaterialId id;
    
    @MapsId("classesId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "classes_id", nullable = false)
    private Classes classes;
    
    @MapsId("materialId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "material_id", nullable = false)
    private Material material;
    
    public ClassesMaterial(ClassesMaterialId id, Classes classes, Material material) {
        this.id = id;
        this.classes = classes;
        this.material = material;
    }
}